<!DOCTYPE html>
<title>Sheriff-o-Matic</title>
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon">
<meta name="viewport" content="width=device-width, minimum-scale=1.0">
<base href="/">
<script src="scripts/clientmon.js"></script>

<script src="bower_components/webcomponentsjs/webcomponents-loader.js"></script>

<script>
window.xsrfToken = '{{.XsrfToken}}';

function loadNonVulcanized() {
  var link = document.createElement('link');
  link.rel = 'import';
  link.href = 'elements/som-app/som-app.html';
  document.documentElement.appendChild(link);
}
</script>
<link rel="import" href="elements/som-app/som-app.vulcanized.html" onerror="loadNonVulcanized()">
<style>
  html {
    height: 100%;
  }

  body {
    font-size: 14px;
    font-family: 'Roboto', 'Noto', sans-serif;
    height: 100%;
    margin: 0;
  }

  .warningBanner {
    background-color: #e75d54;
    font-size: 16px;
    padding: 0.5em 0;
    position: fixed;
    text-align: center;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 100;
  }
</style>
{{if .IsStaging}}
<div class="warningBanner">
  This is the staging server. You might want to use the
  <a href="https://sheriff-o-matic.appspot.com/">production server</a>.
</div>
{{end}}
<som-app user="{{.User}}" trees-json="{{.Trees}}" logout-url="{{.LogoutUrl}}"></som-app>

<script>
  (function(i,s,o,g,r,a,m){i['CrDXObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://storage.googleapis.com/crdx-feedback.appspot.com/feedback.js','crdx');

crdx('setFeedbackButtonLink', 'https://goto.google.com/som-bug');

{{if not .IsDevAppServer}}
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', '{{.AnalyticsID}}', 'auto');
  ga('send', 'pageview');

  // Track client-side navigations as individual page views.
  window.addEventListener('location-changed', function() {
    ga('set', 'page', window.location.pathname);
    ga('send', 'pageview');
  });
{{else}}
  let ga = function(i,s,o,g,r,a,m) {
    console.log('dev mode ga:', i, s, o, g, r, a, m);
  };
{{end}}
</script>
